#include "ULGfx_CrossHair.h"
#include <iostream>
#include <SDL/sprig.h>

VSDL_Image ULG_CrossHair::sourceImage;
static bool imageReady = false;
int imageWidth;
int imageHeight;

void ULG_CrossHair::Init()
{
	int ret;

	if (imageReady){
		return ;
	}else{

		ret = sourceImage.LoadImage(CROSSHAIR_FILE, VSDL_RGB(CROSSHAIR_R, CROSSHAIR_G, CROSSHAIR_B));

		if (ret < 0){
			imageReady = false;
			return ;
		}

		imageWidth = sourceImage.GetImageWidth();
		imageHeight = sourceImage.GetImageHeight();

		sourceImage.SetAlpha(125);
		imageReady = true;
	}

}

ULG_CrossHair::ULG_CrossHair()
{

}

ULG_CrossHair::ULG_CrossHair(VSDL_Point point)
{
	startXY = point;
}

void ULG_CrossHair::OnMouseMove(int mouseX, int mouseY)
{
	startXY.x = mouseX - (imageWidth >> 1);
	startXY.y = mouseY - (imageHeight >> 1);
}

void ULG_CrossHair::Show(SDL_Surface *destSurf)
{
	if (imageReady){
		sourceImage.Blit(destSurf, startXY);
	}
}
